<template>
  <div class="update-name">
    <van-nav-bar
      title="昵称"
      left-text="取消"
      right-text="完成"
      @click-left="$emit('close')"
      @click-right="onconfirm"
    >
    </van-nav-bar>
    <div class="intro-field-wrap">
      <van-field
        v-model="inputName"
        rows="2"
        autosize
        type="textarea"
        maxlength="7"
        placeholder="请输入昵称"
        show-word-limit
      />
    </div>
  </div>
</template>
<script>

export default {
  data() {
    return {
      inputName: this.username
    }
  },
  props: {
    username: {
      type: String,
      required: true
    }
  },
  methods: {
    onconfirm() {
      this.$emit('confirm', this.inputName)
      this.$emit('close')
    }
  }
}
</script>
<style lang="less" scoped>
.intro-field-wrap {
  padding: 10px;
}
</style>